<%--
    Document   : newsercharge
    Created on : Nov 25, 2011, 10:35:41 AM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*, Beans.KhuVuc, Beans.ThoiDiem, Beans.ThamSoHT,Models.ThamSoHT_Model, Models.ThoiDiem_Model, Models.KhuVuc_Model, Models.Ban_Model"%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'msgsercharge', 'rightmsg', 'areaname', 'all', 'timename',  'servicecharge', 'serchargelist', 'notice', 'order' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.
            String all = mdsts[0].getTenTS();
            String areaname = mdsts[1].getTenTS();
            String msgsercharge = mdsts[2].getTenTS();
            String notice = mdsts[3].getTenTS();
            String order = mdsts[4].getTenTS();
            String rightmsg = mdsts[5].getTenTS();
            String serchargelist = mdsts[6].getTenTS();
            String servicecharge = mdsts[7].getTenTS();
            String timename = mdsts[8].getTenTS();

            String msgright = notice + "/" + rightmsg;
            String serchargemsg = notice + "/" + msgsercharge;

            Vector vDSPPV = (Vector) request.getAttribute("DSPPV");
            Vector vDSKV = (Vector) request.getAttribute("DSKV");
            Vector vDSTD = (Vector) request.getAttribute("DSTD");
            int numpage = 0;// khởi tạo số trang = 0
            int vsize = vDSPPV.size();
            if (vsize % 6 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 6;
            } else {
                numpage = vsize / 6 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String sapxep = (String) request.getAttribute("order");
            String test = (String) request.getAttribute("test");
            String sort = (String) request.getAttribute("sort");
            String sortkv = (String) request.getAttribute("sortkv");
            String sx1 = "";
            String sx2 = "";
            String sx3 = "";
            String ud1 = "";
            String ud2 = "";
            String ud3 = "";

            if(sapxep.equals("desc") ){
                   sx1 = "down";
                   sx2 = "down";
                   sx3 = "down";
                   ud1 = "down1";
                   ud2 = "down1";
                   ud3 = "down1";
            }
            
            else if(sapxep.equals("asc") && test.equals("1")){
                    sx1 = "up";
                    sx2 = "down";
                    sx3 = "down";
                    ud1 = "up1";
                    ud2 = "down1";
                    ud3 = "down1";
            }
            else if(sapxep.equals("asc") && test.equals("2")){
                    sx1 = "down";
                    sx2 = "up";
                    sx3 = "down";
                    ud1 = "down1";
                    ud2 = "up1";
                    ud3 = "down1";
            }
            
             else if(sapxep.equals("asc") && test.equals("3")){
                    sx1 = "down";
                    sx2 = "down";
                    sx3 = "up";
                    ud1 = "down1";
                    ud2 = "down1";
                    ud3 = "up1";
             }
            String tenkv = (String) request.getAttribute("tenkv");
            String tentd = (String) request.getAttribute("tentd");
            String pv = (String) request.getAttribute("ppv");

%>

    <div class="title">
        <%=serchargelist%>
        
    </div>
    <div class="content">
        <form name="dsppv" action="">
            <table class="mytable" border="0" cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <th style="width: 15%;"><%=order%></th>
                        <th style=" width: 30%;">
                            <a href="#" id="titledskv1" style="margin-top: 5px;" class="<%=sx1%>" lang="<%=msgright%>" name="1" onclick="SortSearchTenKVPPV(this.className, this.name, this.lang)">
                                <div style="float:left"><%=areaname%></div>
                                <div style=" margin-right: 120px;" id="sortkv1" class="<%=ud1%>"></div>
                            </a>
                        </th>
                        <th style=" width: 30%;">
                            <a href="#" id="titledskv2" style="margin-top: 5px;" class="<%=sx2%>" lang="<%=msgright%>" name="1" onclick="SortSearchTenTDPPV(this.className, this.name, this.lang)">
                                <div style="float:left"><%=timename%></div>
                                <div style=" margin-right: 120px;" id="sortkv2" class="<%=ud2%>"></div>
                            </a>
                        </th>
                        <th>
                            <a href="#" id="titledskv3" style="margin-top: 5px;" class="<%=sx3%>" lang="<%=msgright%>" name="1" onclick="SortSearchPPV(this.className, this.name, this.lang)">
                                <div style="float:left"><%=servicecharge%></div>
                                <div style=" margin-right: 90px;" id="sortkv3" class="<%=ud3%>"></div>
                            </a>
                        </th>
                    </tr>
                    <tr id="searchPPV" >
                        <th><img onclick="SearchSerCharge( this.alt, this.lang)" lang="<%=msgright%>" style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;" alt="1" src="../images/search1.png"></th>
                        <th>
                            <select style="width: 130px; height: 25px; padding-bottom: 2px; padding-top: 2px;"  lang="<%=msgright%>" id="1"  class="tenkv text" onchange="SearchSerCharge( this.id, this.lang)">
                                <%
                                    if(tenkv.equals("all")){%>
                                        <option value="all"><%=all%></option>
                                <%
                                    for(int i=0; i<vDSKV.size(); i++){
                                        Beans.KhuVuc kvv = (Beans.KhuVuc) vDSKV.elementAt(i);%>
                                        <option value="<%=kvv.getMaKV() %>"><%=kvv.getTenKV() %></option>
                                <%  }%>
                                <%  }
                                    else{%>
                                    <option value="<%=tenkv %>"><%=Ban_Model.LayTenKV(Integer.parseInt(tenkv), langid)%></option>
                                <%
                                    KhuVuc[] dskvv = KhuVuc_Model.DSKhuVuc(Integer.parseInt(tenkv), langid);
                                        for (int k = 0; k < dskvv.length; k++) {%>
                                <option value="<%=dskvv[k].getMaKV() %>"><%=dskvv[k].getTenKV() %></option>
                                <%  }
                                %>
                                <%  }%>
                                <%
                                    if(!tenkv.equals("all")){%>
                                        <option value="all"><%=all%></option>
                                <%  }
                                %>
                            </select>
                        </th>
                        <th>
                            <select style="width: 130px; height: 25px; padding-bottom: 2px; padding-top: 2px;" lang="<%=msgright%>" id="1"  class="tentd text" onchange="SearchSerCharge( this.id, this.lang)">
                                <%
                                    if(tentd.equals("all")){%>
                                        <option value="all"><%=all%></option>
                                <%
                                    for(int i=0; i<vDSTD.size(); i++){
                                        Beans.ThoiDiem tdd = (Beans.ThoiDiem) vDSTD.elementAt(i);%>
                                        <option value="<%=tdd.getMaTD() %>"><%=tdd.getTenTD() %></option>
                                <%  }%>
                                <%  }
                                    else{%>
                                    <option value="<%=tentd %>"><%=ThoiDiem_Model.LayTenTD(Integer.parseInt(tentd), langid)  %></option>
                                <%
                                    ThoiDiem[] dstdd = ThoiDiem_Model.DSThoiDiem(Integer.parseInt(tentd), langid);
                                        for (int k = 0; k < dstdd.length; k++) {%>
                                        <option value="<%=dstdd[k].getMaTD() %>"><%=ThoiDiem_Model.LayTenTD(dstdd[k].getMaTD(), langid)  %></option>
                                <%  }
                                %>
                                <%  }%>
                                <%
                                    if(!tentd.equals("all")){%>
                                        <option value="all"><%=all%></option>
                                <%  }
                                %>
                            </select>
                        </th>
                        <th>
                            <input type="textbox" value="<%=pv%>" maxlength="2" style=" width: 50px; margin-right: 10px;"  class="ppv text"  onkeypress="return keypress(event)">%
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <%
                        for (int i = (item - 1) * 6; i < (item - 1) * 6 + 6 && i < vsize; i++) {
                            Beans.PhiPV ppv = (Beans.PhiPV) vDSPPV.elementAt(i);
                    %>
                    <tr>
                        <td class="STT"><%= i + 1%></td>
                        <td><%=Ban_Model.LayTenKV(ppv.getMaKV(), langid) %></td>
                        <td><%=ThoiDiem_Model.LayTenTD(ppv.getMaTD(), langid)  %></td>
                        <td><input type="textbox" alt="<%=ppv.getMaKV()%>" id="<%=ppv.getMaTD()%>" name="<%=msgright%>" lang="<%=serchargemsg%>" onchange="UpdatePPV(this.value, this.alt, this.id, this.name, this.lang)" class="text" style=" width: 50px; margin-right: 10px; float: left;" value="<%=ppv.getPhiPV() %>" maxlength="2" onkeypress="return keypress(event)">%<img style=" margin-left: 20px; width: 17px; margin-top: 2px; cursor: pointer;" alt="" src="../images/edit.png"></td>
                    </tr>
                    <%  } %>
                </tbody>
            </table>
            <div class="pagination">
                <%
                    int trang = 1;
                    if (item > 1) {
                        trang = item - 1;
                    }
                %>
                <%
                    if (vsize > 6) {%>
                <%
                    if(sortkv.equals("tenkv")){%>
                        <a href="#" id="<%=sort%>" class="prev"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortSearchTenKVPPV(this.id, this.name, this.lang)">«</a>
                <%  }
                    else if(sortkv.equals("tentd")){%>
                        <a href="#" id="<%=sort%>" class="prev"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortSearchTenTDPPV(this.id, this.name, this.lang)">«</a>
                <%  }
                    else{%>
                        <a href="#" id="<%=sort%>" class="prev"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortSearchPPV(this.id, this.name, this.lang)">«</a>
                <%  }
                %>

                <%  for (int c = 1; c <= numpage; c++) {
                        if (c != item) {
                %>
                <%
                    if(sortkv.equals("tenkv")){%>
                        <a href="#" id="<%=sort%>"  name="<%= c%>" lang="<%=msgright%>" onclick="SortSearchTenKVPPV(this.id, this.name, this.lang)"><%= c%></a>
                <%  }
                    else if(sortkv.equals("tentd")){%>
                        <a href="#" id="<%=sort%>"   name="<%= c%>" lang="<%=msgright%>" onclick="SortSearchTenTDPPV(this.id, this.name, this.lang)"><%= c%></a>
                <%  }
                    else{%>
                        <a href="#" id="<%=sort%>"   name="<%= c%>" lang="<%=msgright%>" onclick="SortSearchPPV(this.id, this.name, this.lang)"><%= c%></a>
                <%  }
                %>

                <%      } else {%><a class="current"> <%= c%></a> <% }
                    }
                %>
                <%
                    if (item + 1 <= numpage) {
                        trang = item + 1;
                    } else {
                        trang = item;
                    }
                %>
                <%
                    if(sortkv.equals("tenkv")){%>
                        <a href="#" id="<%=sort%>" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortSearchTenKVPPV(this.id, this.name, this.lang)">»</a>
                <%  }
                    else if(sortkv.equals("tentd")){%>
                        <a href="#" id="<%=sort%>" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortSearchTenTDPPV(this.id, this.name, this.lang)">»</a>
                <%  }
                    else{%>
                        <a href="#" id="<%=sort%>" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="SortSearchPPV(this.id, this.name, this.lang)">»</a>
                <%  }
                %>

                <%  }
                %>
            </div>
        </form>
    </div>
